//
//  SuggestionViewController.m
//  南京大牌档
//
//  Created by student on 14-1-16.
//  Copyright (c) 2014年 无锡第三团队. All rights reserved.
//

#import "SuggestionViewController.h"

@interface SuggestionViewController ()

@end

@implementation SuggestionViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.hidesBottomBarWhenPushed=YES;
        self.tabBarController.tabBar.hidden=YES;
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	self.view.backgroundColor=[UIColor lightGrayColor];
    
    UIControl *tempControl=[[UIControl alloc]initWithFrame:CGRectMake(0, 0, 320, WXHLApplicationBounds().size.height)];
    [tempControl addTarget:self action:@selector(backgroundPressed) forControlEvents:UIControlEventTouchDown];
    tempControl.backgroundColor=[UIColor clearColor];
    [self.view  addSubview:tempControl];
    
    [self loadLabel];
    
    [self loadText];
    
    [self loadButton];

}

-(void)loadText
{
    suggestionTextView = [[UITextView alloc] initWithFrame:CGRectMake(10, 135, 300, 200)];
    suggestionTextView.backgroundColor = [UIColor whiteColor];
    suggestionTextView.font = [UIFont boldSystemFontOfSize:18];
    suggestionTextView.layer.cornerRadius=5;
    
    suggestionTextView.delegate=self;
    [self.view addSubview:suggestionTextView];
   
}

- (void)backgroundPressed
{
    [suggestionTextView resignFirstResponder];
}
-(void)loadLabel
{
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(95, 80, 125, 30)];
    label.font = [UIFont boldSystemFontOfSize:30];
    label.text = @"意见反馈";
    
    [self.view addSubview:label];
    
    
}

- (void)loadButton
{
    
    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(120, 360, 100, 40)];
    button.backgroundColor=[UIColor whiteColor];
    button.layer.cornerRadius=5;
   
    [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [button setTitle:@"提交" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(ddd) forControlEvents:UIControlEventTouchUpInside];
    button.showsTouchWhenHighlighted = YES;
    [self.view addSubview:button];
    
}

-(void)ddd
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"是否提交" message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil];
    [alert show];
    
    
    
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    
    if (buttonIndex==1) {
        
        activity=[[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(145,165, 30, 30)];
        activity.activityIndicatorViewStyle=UIActivityIndicatorViewStyleGray;
        activity.tag=600;
        activity.hidesWhenStopped=YES;
        [activity startAnimating];
        [self.view addSubview:activity];
        
        time = [NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(lTime) userInfo:nil repeats:NO];
        
    }
    
}

-(void)lTime
{
    [activity removeFromSuperview];
    suggestionTextView.text = @"";
    UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:@"提交成功,谢谢！" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
    [alert1 show];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
